package com.gps.skyrc.bean;

import android.os.Parcel;
import android.os.Parcelable;

import org.litepal.annotation.Column;
import org.litepal.crud.LitePalSupport;

/**
 * Create by ywq
 * data 2018/11/29
 */
public class DeviceInfo extends LitePalSupport implements Parcelable {
    private long id;
    private String name = "";
    @Column(unique = true)
    private String mac = "";
    @Column(ignore = true)
    private boolean isLine;
    private int satelliteNum;//卫星数
    private double hdop;
    private int voltagePercent;//电压
    private int isHaveNewMsg = 0;
    private int isTesting = 0;
    private int testMode;
    private Float version = 1.00f;
    private int gpsBtnStatue = 0;//0打开  1关闭

    public DeviceInfo() {
    }


    protected DeviceInfo(Parcel in) {
        id = in.readLong();
        name = in.readString();
        mac = in.readString();
        isLine = in.readByte() != 0;
        satelliteNum = in.readInt();
        hdop = in.readDouble();
        voltagePercent = in.readInt();
        isHaveNewMsg = in.readInt();
        isTesting = in.readInt();
        testMode = in.readInt();
        if (in.readByte() == 0) {
            version = null;
        } else {
            version = in.readFloat();
        }
        gpsBtnStatue = in.readInt();
    }

    public static final Creator<DeviceInfo> CREATOR = new Creator<DeviceInfo>() {
        @Override
        public DeviceInfo createFromParcel(Parcel in) {
            return new DeviceInfo(in);
        }

        @Override
        public DeviceInfo[] newArray(int size) {
            return new DeviceInfo[size];
        }
    };

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public boolean isLine() {
        return isLine;
    }

    public void setLine(boolean line) {
        isLine = line;
    }

    public int getSatelliteNum() {
        return satelliteNum;
    }

    public void setSatelliteNum(int satelliteNum) {
        this.satelliteNum = satelliteNum;
    }

    public double getHdop() {
        return hdop;
    }

    public void setHdop(double hdop) {
        this.hdop = hdop;
    }

    public int getVoltagePercent() {
        return voltagePercent;
    }

    public void setVoltagePercent(int voltage) {
        this.voltagePercent = voltage;
    }

    public int getIsHaveNewMsg() {
        return isHaveNewMsg;
    }

    public void setIsHaveNewMsg(int isHaveNewMsg) {
        this.isHaveNewMsg = isHaveNewMsg;
    }

    public int getIsTesting() {
        return isTesting;
    }

    public void setIsTesting(int isTesting) {
        this.isTesting = isTesting;
    }

    public int getTestMode() {
        return testMode;
    }

    public void setTestMode(int testMode) {
        this.testMode = testMode;
    }

    public Float getVersion() {
        return version;
    }

    public void setVersion(Float version) {
        this.version = version;
    }

    public int getGpsBtnStatue() {
        return gpsBtnStatue;
    }

    public void setGpsBtnStatue(int gpsBtnStatue) {
        this.gpsBtnStatue = gpsBtnStatue;
    }

    @Override
    public String toString() {
        return "DeviceInfo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", mac='" + mac + '\'' +
                ", isLine=" + isLine +
                ", satelliteNum=" + satelliteNum +
                ", hdop=" + hdop +
                ", voltagePercent=" + voltagePercent +
                ", isHaveNewMsg=" + isHaveNewMsg +
                ", isTesting=" + isTesting +
                ", testMode=" + testMode +
                ", version=" + version +
                ", gpsBtnStatue=" + gpsBtnStatue +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(id);
        dest.writeString(name);
        dest.writeString(mac);
        dest.writeByte((byte) (isLine ? 1 : 0));
        dest.writeInt(satelliteNum);
        dest.writeDouble(hdop);
        dest.writeInt(voltagePercent);
        dest.writeInt(isHaveNewMsg);
        dest.writeInt(isTesting);
        dest.writeInt(testMode);
        if (version == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeFloat(version);
        }
        dest.writeInt(gpsBtnStatue);
    }
}
